package net.sppan.base.service.impl;

import net.sppan.base.dao.IDepartmentDao;
import net.sppan.base.dao.IEmployeeDao;
import net.sppan.base.entity.Department;
import net.sppan.base.entity.Employee;
import net.sppan.base.service.DeparmentService;
import net.sppan.base.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/** 
 * @Description: 职工service
 * @Param:  
 * @return:  
 * @Author:
 */
@Service
public class DepartmentServiceImpl implements DeparmentService {
    @Autowired
    private IDepartmentDao iDepartmentDao;
	@Override
	public List<Department> getDepartmentList() {
		return iDepartmentDao.getDepartmentList();
	}
	@Override
	public void saveDepartment(Department department) {
		Department entity = iDepartmentDao.getDepartment(department.getId());
		if(entity != null){
			//员工已经存在则更新
			iDepartmentDao.updateDepartment(department);
			return;
		}
		//如果没有则新增
		iDepartmentDao.savaDepartment(department);
	}

	@Override
	public List<Department> getAllDepartments() {
		return iDepartmentDao.gegetAllDepartments();
	}

	@Override
	public Department getDepartment(Integer id) {
		return iDepartmentDao.getDepartment(id);
	}

	@Override
	public int deleteDepartment(Integer id) {
		return iDepartmentDao.deleteDepartment(id);
	}
}
